(() => {
    if (JSON.parse(localStorage.getItem('usrData'))) {
        // console.log(JSON.parse(localStorage.getItem('usrData')));
        const {
            usr,
            token
        } = JSON.parse(localStorage.getItem('usrData'));
        $('.top-nav-login').addClass('dorpdown').html(`
            <div class="dt cw-icon">
                ${usr}
            </div>
            <div class="dd dorpdown-layer">
                <div class="dd-spacer"></div>
                <div class="item">
                    <a class='logout' href="javascript:void(0);">注销</a>
                </div>
                <div class="item">
                    <a class='change-usr' href="javascript:void(0);">切换账号</a>
                </div>
            </div>
        `);
        $('.logout').off('click').on('click', () => {
            localStorage.removeItem('usrData');
            location.reload();
        })
        $('.change-usr').off('click').on('click', () => {
            localStorage.removeItem('usrData');
            location.href = '/pages/login.html';
        })
    }
})()